*Load Data
use "C:\Users\Eliza\Desktop\cdsns_pseudodata.dta", clear

*Table 1
ttest lcdsns if eventmonth==1&timematched==1&baselinesample==1, by(eventfirm)
ttest cdsns if eventmonth==1&timematched==1&baselinesample==1, by(eventfirm)
ttest dcdsns if eventmonth==1&timematched==1&baselinesample==1, by(eventfirm)
ttest lcdsns if eventmonth==1&timeff12matched==1&baselinesample==1, by(eventfirm)
ttest cdsns if eventmonth==1&timeff12matched==1&baselinesample==1, by(eventfirm)
ttest dcdsns if eventmonth==1&timeff12matched==1&baselinesample==1, by(eventfirm)
ttest lcdsns if eventmonth==1&timeff12countrymatched==1&baselinesample==1, by(eventfirm)
ttest cdsns if eventmonth==1&timeff12countrymatched==1&baselinesample==1, by(eventfirm)
ttest dcdsns if eventmonth==1&timeff12countrymatched==1&baselinesample==1, by(eventfirm)

*Table 2
duplicates drop gvkey if baselinesample==1, force
estpost tabulate region if baselinesample==1
estimates store m1
estpost tabulate country if baselinesample==1
estimates store m2
estpost tabulate sector if baselinesample==1
estimates store m3
esttab m1 m2 m3 using C:\Users\Eliza\Desktop\cdsns\Table2.csv,nogap replace

*Table 3
use "C:\Users\Eliza\Desktop\cdsns_pseudodata.dta", clear
estpost tabstat cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk stockns if baselinesample==1, listwise statistics(mean sd p25 p50 p75) columns(statistics) 
estimates store m1
estpost tabstat creditorrights if baselinesample==1, listwise statistics(mean) columns(statistics) by(country)
estimates store m2
esttab m1 m2 using C:\Users\Eliza\Desktop\cdsns\Table3.csv, replace cells("mean sd p25 p50 p75") 

*Table 4
estpost correlate cdsns creditorrights propertyrights shareholderrights vix if baselinesample==1, matrix listwise
est store m1
esttab m1 using C:\Users\Eliza\Desktop\cdsns\Table4.csv, unstack not noobs compress replace 

*Table 5a
reghdfe cdsns creditorrights if baselinesample==1, absorb(year sic2) cluster(countrysic2)
est store m1
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(year sic2) cluster(countrysic2)
est store m2
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if threefactorsample==1, absorb(yearsic2) cluster(countrysic2)
est store m4
esttab m1 m2 m3 m4 using C:\Users\Eliza\Desktop\cdsns\Table5a.csv, keep(creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons) order(creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 5b
reghdfe cdsns limitreorganization propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(yearsic2) cluster(countrysic2)
est store m1
reghdfe cdsns noautostayonassets propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(yearsic2) cluster(countrysic2)
est store m2
reghdfe cdsns creditorpaidfirst propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns nostaymanagement propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(yearsic2) cluster(countrysic2)
est store m4
reghdfe cdsns limitreorganization noautostayonassets creditorpaidfirst nostaymanagement propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(yearsic2) cluster(countrysic2)
est store m5
esttab m1 m2 m3 m4 m5 using C:\Users\Eliza\Desktop\cdsns\Table5b.csv, keep(limitreorganization noautostayonassets creditorpaidfirst nostaymanagement propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons) order(limitreorganization noautostayonassets creditorpaidfirst nostaymanagement propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 6a
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&investmentgrade==1, absorb(yearsic2) cluster(countrysic2)
est store m1
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&investmentgrade==0, absorb(yearsic2) cluster(countrysic2)
est store m2
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&capexq==0, absorb(yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&capexq==1, absorb(yearsic2) cluster(countrysic2)
est store m4
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&assetgrowthq==0, absorb(yearsic2) cluster(countrysic2)
est store m5
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&assetgrowthq==1, absorb(yearsic2) cluster(countrysic2)
est store m6
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&ppegrowthq==0, absorb(yearsic2) cluster(countrysic2)
est store m7
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&ppegrowthq==1, absorb(yearsic2) cluster(countrysic2)
est store m8
esttab m1 m2 m3 m4 m5 m6 m7 m8 using C:\Users\Eliza\Desktop\cdsns\Table6a.csv, keep(creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons) order(creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 6b
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&bidaskq==0, absorb(yearsic2) cluster(countrysic2)
est store m1
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&bidaskq==1, absorb(yearsic2) cluster(countrysic2)
est store m2
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&amihudq==0, absorb(yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1&amihudq==1, absorb(yearsic2) cluster(countrysic2)
est store m4
esttab m1 m2 m3 m4 using C:\Users\Eliza\Desktop\cdsns\Table6b.csv, keep(creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons) order(creditorrights propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk  _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 7
reghdfe cdsns reform if baselinesample==1, absorb(year sic2) cluster(countrysic2)
est store m1
reghdfe cdsns reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(year sic2) cluster(countrysic2)
est store m2
reghdfe cdsns reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m4
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m5
esttab m1 m2 m3 m4 m5 using C:\Users\Eliza\Desktop\cdsns\Table7.csv, keep(reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud  _cons) order(reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud  _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 8
reghdfe leverage reform vix assetsus markettobook recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m1
reghdfe capex reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m2
reghdfe assetgrowth reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud capex assetgrowth if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m4
esttab m1 m2 m3 m4 using C:\Users\Eliza\Desktop\cdsns\Table8.csv, keep(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud capex assetgrowth _cons) order(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud capex assetgrowth _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 9a
use "C:\Users\Eliza\Desktop\cdsns_matchedsample_pseudodata.dta", clear
reghdfe cdsns reform if baselinesample==1, absorb(cohort year sic2) cluster(countrysic2)
est store m1
reghdfe cdsns reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(cohort year sic2) cluster(countrysic2)
est store m2
reghdfe cdsns reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(cohort yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country cohort yearsic2) cluster(countrysic2)
est store m4
esttab m1 m2 m3 m4 using C:\Users\Eliza\Desktop\cdsns\Table9a.csv, keep(reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud  _cons) order(reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud  _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 9b
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1&postgfc==1, absorb(country cohort yearsic2) cluster(countrysic2)
est store m1
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud cdsmarketsize if baselinesample==1, absorb(country cohort yearsic2) cluster(countrysic2)
est store m2
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if xrsample==1, absorb(country cohort yearsic2) cluster(countrysic2)
est store m3
esttab m1 m2 m3 using C:\Users\Eliza\Desktop\cdsns\Table9b.csv, keep(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud cdsmarketsize _cons) order(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud cdsmarketsize _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table 9c
reghdfe cdsns reform if baselinesample==1&europecontrolgroup==1, absorb(cohort year sic2) cluster(countrysic2)
est store m1
reghdfe cdsns reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1&europecontrolgroup==1, absorb(cohort year sic2) cluster(countrysic2)
est store m2
reghdfe cdsns reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1&europecontrolgroup==1, absorb(cohort yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1&europecontrolgroup==1, absorb(country cohort yearsic2) cluster(countrysic2)
est store m4
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if xrsample==1&europecontrolgroup==1, absorb(country cohort yearsic2) cluster(countrysic2)
est store m5
esttab m1 m2 m3 m4 m5 using C:\Users\Eliza\Desktop\cdsns\Table9c.csv, keep(reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud  _cons) order(reform propertyrights shareholderrights vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud  _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table A3
use "C:\Users\Eliza\Desktop\cdsns_pseudodata.dta", clear
estpost tabstat recoveryrate if baselinesample==1, listwise statistics(mean) columns(statistics) by(sector)
estimates store m1
esttab m1 using C:\Users\Eliza\Desktop\cdsns\TableA3.csv, replace cells("mean") 

*Table A6
estpost tabstat cdsns creditorrights propertyrights shareholderrights assetsus markettobook leverage recoveryrate jumprisk if baselinesample==1, listwise statistics(mean) columns(statistics) by(country)
estimates store m1
esttab m1 using C:\Users\Eliza\Desktop\cdsns\TableA6.csv, replace cells("mean")

*Table A7
reghdfe cdsnscorr1 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m1
reghdfe cdsnscorr2 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m2
reghdfe cdsnscorr3 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m3
reghdfe cdsnscorr4 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m4
reghdfe cdsnscorr5 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m5
reghdfe cdsnscorr6 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m6
reghdfe cdsnscorr7 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m7
reghdfe cdsnscorr8 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m8
reghdfe cdsnscorr9 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m9
reghdfe cdsnscorr10 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m10
reghdfe cdsnscorr11 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m11
reghdfe cdsnscorr12 reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(countrysic2)
est store m12
esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 using C:\Users\Eliza\Desktop\cdsns\TableA7.csv, keep(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud _cons) order(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)

*Table A8
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1&lessthan5countries==0, absorb(country yearsic2) cluster(countrysic2)
est store m1
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1&lessthan10countries==0, absorb(country yearsic2) cluster(countrysic2)
est store m2
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(sic2)
est store m3
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(gvkey)
est store m4
reghdfe cdsns reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud if baselinesample==1, absorb(country yearsic2) cluster(year)
est store m5
esttab m1 m2 m3 m4 m5 using C:\Users\Eliza\Desktop\cdsns\TableA8.csv, keep(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud _cons) order(reform vix assetsus markettobook leverage recoveryrate jumprisk gdpcapita stockns amihud _cons ) replace ar2 csv nogap star(* 0.10 ** 0.05 *** 0.01) b(3) t(3)
